﻿using GenericWin;
using ModelEntities.Adapter;
using ReprisePV.ViewModels;
using GeneralServices.ViewModel;

namespace ReprisePV.Views
{
    /// <summary>
    /// Logique d'interaction pour DetailsPV.xaml
    /// </summary>
    public partial class DetailPV : GenericUserControl
    {
        public DetailPV()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Affectation du PV du view model pour pouvoir binder dessus
        /// </summary>
        /// <param name="pv"></param>
        public DetailPV(MEntetePV pv)
            :this()
        {
            //DetailPV_VM viewModel = ServicesSingle.Get<DetailPV_VM>();
            //this.Resources.Add("vmDetail", viewModel);

            DetailPV_VM viewModel = this.Resources["vmDetail"] as DetailPV_VM;

            if(viewModel != null)
            {
                VM = viewModel;
                viewModel.PVOrigin = pv;
                viewModel.PV = pv;
            }
        }

        public override ViewModelBase ExposeViewModel()
        {
            return VM;
        }
    }
}
